var status = 0;
var minLevel = 120;
var maxLevel = 255;
var minPartySize = 1;
var maxPartySize = 6;
var name0 = "[BOSS]暴力熊单人任务";
var name1 = "[执行]暴力熊单人任务";
var EventManager = "Baolixiong";
var EventName = "暴力熊";

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(g, h, j) {
    if (g == -1) {
        cm.dispose()
    } else {
        if (g == 0 && status == 0) {
            cm.dispose();
            return
        }
        if (g == 1) {
            status++
        } else {
            status--
        }
        if (cm.getMapId() == 253000003) {
            cm.dispose();
            cm.openNpc(2091113, "因贝尔诺BOSS")
        } else {
            if (status == 0) {
                cm.askMenu("#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#亲爱的#r#h ##k您好，" + name0 + ":\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/startcondition#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0##r所有线可挑战。\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0##r所属队长与我对话执行。\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#组队员等级必须要在" + minLevel + "级以上。\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#组队员必须要" + minPartySize + "人以上，" + maxPartySize + "人以下。#b\r\n\r\n#fUI/UIWindow2.img/QuestGuide/Button/WorldMapQuestToggle/normal/0#\r\n#L0##fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#" + name1 + "#l")
            } else {
                if (status == 1) {
                    if (j == 0) {
                        if (cm.getParty() == null) {
                            cm.sendOk("请组队后和我谈话。");
                            cm.dispose()
                        } else {
                            if (!cm.isLeader()) {
                                cm.sendOk("队长必须在这里。请让他和我说话。");
                                cm.dispose()
                            } else {
                                var c = cm.getParty().getMembers();
                                var k = cm.getPlayer().getMapId();
                                var f = true;
                                var i = 0;
                                var d = 0;
                                var e = c.iterator();
                                while (e.hasNext()) {
                                    var l = e.next();
                                    if ((l.getLevel() >= minLevel) && (l.getLevel() <= maxLevel)) {
                                        i += 1
                                    } else {
                                        f = false
                                    }
                                    if (l.getMapId() == k) {
                                        d += 1
                                    }
                                }
                                if (c.size() < minPartySize || c.size() > maxPartySize || d < minPartySize) {
                                    f = false
                                }
                                if (f) {
                                    var b = cm.getEventManager("" + EventManager + "");
                                    if (b == null) {
                                        cm.sendOk("此任务正在建设当中。")
                                    } else {
                                        var a = b.getNumberProperty("state");
                                        if (a.equals("0") || a == null) {
                                            b.startInstance(cm.getParty(), cm.getMap(), 198);
                                            cm.dispose();
                                            return
                                        } else {
                                            cm.sendOk("" + name0 + "任务里面已经有人了，请稍等！")
                                        }
                                    }
                                    cm.dispose()
                                } else {
                                    cm.sendOk("请先开设组队,请确认你的组队员：\r\n\r\n#b1、组队员必须要" + minPartySize + "人以上，" + maxPartySize + "人以下。\r\n2、组队员等级必须要在" + minLevel + "级以上。\r\n\r\n（#r如果仍然错误, 重新下线,再登陆 或者请重新组队。#k#b）");
                                    cm.dispose()
                                }
                            }
                        }
                    } else {
                        if (j == 1) {
                            cm.sendOk("请确认你的组队员：\r\n\r\n#b1、组队员必须要" + minPartySize + "人以上，" + maxPartySize + "人以下。\r\n2、组队员等级必须要在" + minLevel + "级以上。\r\n\r\n（#r如果仍然错误, 重新下线,再登陆 或者请重新组队。#k#b）");
                            cm.dispose()
                        }
                    }
                }
            }
        }
    }
};